home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / 3DGPL 1.0 / CODE / GRAPHICS / GRP-TEXT.C < prev   
Encoding:
C/C++ Source or Header  |  1997-03-08  |  3.9 KB  |  86 lines  |  [TEXT/MACA]

  1. /** 3DGPL *************************************************\
  2.  * (8bit deep bitmap)                                     *
  3.  * 2D graphics and 2D clipping.                           *
  4.  *                                                        *
  5.  *  Defines:                                              *
  6.  *   G_text                  rendering a text string.     *
  7.  *                                                        *
  8.  *  (6/1995) By Sergei Savhenko. (savs@cs.mcgill.ca).     *
  9.  *  Copyright (c) 1995 Sergei Savchenko.                  *
  10.  *  THIS SOURCE CODE CAN'T BE USED FOR COMERCIAL PURPOSES *
  11.  *  WITHOUT AUTHORISATION                                 *
  12. \**********************************************************/
  13.  
  14. #ifdef __MWERKS__
  15. #include "hardware.h"           /* hardware specific stuff */
  16. #include "graphics.h"           /* graphics functions */
  17. #else
  18. #include "../hardware/hardware.h"           /* hardware specific stuff */
  19. #include "../graphics/graphics.h"           /* graphics functions */
  20. #endif
  21.  
  22. extern unsigned char *G_buffer;             /* the bitmap's bits */
  23.  
  24. unsigned char G_font[354]=                  /* The 8x6 font */
  25.  0x00,0x00,0x00,0x00,0x00,0x00, 0x30,0x30,0x30,0x00,0x30,0x00,
  26.  0xd8,0x90,0x00,0x00,0x00,0x00, 0x6c,0xfe,0x6c,0xfe,0x6c,0x00,
  27.  0x7e,0xd0,0x7c,0x16,0xfc,0x00, 0xcc,0x18,0x30,0x60,0xcc,0x00,
  28.  0x60,0x90,0x74,0xd8,0x6c,0x00, 0x30,0x20,0x00,0x00,0x00,0x00,
  29.  0x60,0xc0,0xc0,0xc0,0x60,0x00, 0x18,0x0c,0x0c,0x0c,0x18,0x00,
  30.  0x6c,0x38,0xfe,0x38,0x6c,0x00, 0x00,0x30,0xfc,0x30,0x00,0x00,
  31.  0x00,0x00,0x00,0x30,0x20,0x00, 0x00,0x00,0x7c,0x00,0x00,0x00,
  32.  0x00,0x00,0x00,0x00,0xc0,0x00, 0x0c,0x18,0x30,0x60,0xc0,0x00,
  33.  0x78,0x84,0x84,0x84,0x78,0x00, 0x04,0x0c,0x14,0x04,0x04,0x00,
  34.  0x78,0x84,0x18,0x20,0x7c,0x00, 0x78,0x04,0x38,0x04,0x78,0x00,
  35.  0x84,0x84,0xfc,0x04,0x04,0x00, 0xfc,0x80,0xf8,0x04,0xf8,0x00,
  36.  0x30,0x40,0xf8,0x84,0x78,0x00, 0xfc,0x04,0x08,0x10,0x10,0x00,
  37.  0x78,0x84,0x78,0x84,0x78,0x00, 0x78,0x84,0x7c,0x08,0x30,0x00,
  38.  0x00,0x30,0x00,0x30,0x00,0x00, 0x00,0x30,0x00,0x30,0x20,0x00,
  39.  0x30,0x60,0xc0,0x60,0x30,0x00, 0x00,0x7c,0x00,0x7c,0x00,0x00,
  40.  0x30,0x18,0x0c,0x18,0x30,0x00, 0x78,0xcc,0x18,0x00,0x18,0x00,
  41.  0x78,0xcc,0xdc,0xc0,0x7c,0x00, 0x30,0x48,0x84,0xfc,0x84,0x00,
  42.  0xf8,0x84,0xf8,0x84,0xf8,0x00, 0x7c,0x80,0x80,0x80,0x7c,0x00,
  43.  0xf8,0x84,0x84,0x84,0xf8,0x00, 0xfc,0x80,0xf0,0x80,0xfc,0x00,
  44.  0xfc,0x80,0xf0,0x80,0x80,0x00, 0x7c,0x80,0x84,0x84,0x7c,0x00,
  45.  0x84,0x84,0xfc,0x84,0x84,0x00, 0x10,0x10,0x10,0x10,0x10,0x00,
  46.  0x04,0x04,0x04,0x84,0x78,0x00, 0x84,0x88,0xf0,0x88,0x84,0x00,
  47.  0x80,0x80,0x80,0x80,0xfc,0x00, 0x82,0xc6,0xaa,0x92,0x82,0x00,
  48.  0x84,0xc4,0xa4,0x94,0x8c,0x00, 0x78,0x84,0x84,0x84,0x78,0x00,
  49.  0xf8,0x84,0xf8,0x80,0x80,0x00, 0x78,0x84,0x84,0x78,0x1c,0x00,
  50.  0xf8,0x84,0xf8,0x90,0x88,0x00, 0x7c,0x80,0x78,0x04,0xf8,0x00,
  51.  0xfe,0x10,0x10,0x10,0x10,0x00, 0x84,0x84,0x84,0x84,0x78,0x00,
  52.  0x84,0x84,0x84,0x48,0x30,0x00, 0x82,0x82,0x92,0xaa,0x44,0x00,
  53.  0x84,0x48,0x30,0x48,0x84,0x00, 0x88,0x88,0x50,0x20,0x20,0x00,
  54.  0xf8,0x10,0x20,0x40,0xf8,0x00
  55. };
  56.  
  57. /**********************************************************\
  58.  *  Rendering a text string, no clipping is performed !   *
  59. \**********************************************************/
  60.  
  61. void G_text(int x,int y,char *string,register unsigned char colour)
  62. {
  63.  int nm,i,j;
  64.  unsigned char  cur;
  65.  unsigned char  *adr,*l_adr;
  66.  
  67.  adr=G_buffer+HW_SCREEN_X_SIZE*y+x;         /* Where in the screen buffer */
  68.  
  69.  while(*string!='\0')                       /* until the end of the string */
  70.  {
  71.   nm=((*string++)-' ');                     /* Starting from space */
  72.   if(nm>58) nm-=' ';                        /* to uppercase 58='Z'-' ' */
  73.   nm*=6;                                    /* 6 bytes per char */
  74.   for(i=0,l_adr=adr;i<6;i++,l_adr+=HW_SCREEN_X_SIZE)
  75.   {
  76.    cur=G_font[nm++];
  77.    for(j=0;j<8;j++)
  78.     if(cur&(0x80>>j)) *(l_adr+j)=colour;
  79.   }
  80.   adr+=8;                                   /* Next word */
  81.  }
  82. }
  83.  
  84. /**********************************************************/
  85.